﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Refugees.Views.Windows
{
    /// <summary>
    /// Логика взаимодействия для OrganizationEdit.xaml
    /// </summary>
    public partial class OrganizationEdit : Window
    {
        Models.Organization organization;
        Repositories.OrganizationRepository repository = new Repositories.OrganizationRepository();

        public OrganizationEdit(Models.Organization organization)
        {
            InitializeComponent();
            this.organization = organization;
            DataContext = organization;
        }

        public OrganizationEdit()
        {
            InitializeComponent();
            organization = new Models.Organization();
            DataContext = organization;
            repository.AddOrganization(organization);
        }

        private void SaveClick(object sender, RoutedEventArgs e)
        {
            if (Repositories.ModelRepository.Save())
            {
                MessageBox.Show("Данные сохранены успешно");
            }
            else
            {
                MessageBox.Show("Данные не сохранены. Повторите попытку позже или проверьте данные");
            }
        }

        private void BackClick(object sender, RoutedEventArgs e)
        {
            new ContactNumbers().Show();
            Close();
        }
    }
}
